package com.central.common.feign.fallback

import com.central.common.enum.LikeTypeEnum
import com.central.common.feign.AttentionService
import com.central.common.feign.LikeService
import com.central.common.model.RealDataResult
import feign.hystrix.FallbackFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 * @author  fly
 * @date  2021/5/27 17:28
 * @version 1.0
 */
open class LikeServiceFallbackFactory : FallbackFactory<LikeService>{

    private val log: Logger = LoggerFactory.getLogger(LikeServiceFallbackFactory::class.java)


    override fun create(p0: Throwable?): LikeService = object : LikeService {

        override fun getLikeNum(likeId: Long, likeTypeEnum: LikeTypeEnum): RealDataResult {

            log.error("获取$likeId 的点赞个数失败, 失败原因是 $p0")
            return RealDataResult()
        }

        override fun booleanLike(likeId: Long, userId: Long, likeTypeEnum: LikeTypeEnum): RealDataResult {

            log.error("获取$userId 是否点赞 $likeId 失败, 失败原因是 $p0")
            return RealDataResult()
        }


    }
}
